﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Marta.buchalska.wesele.Admin.Offer
{
    public partial class Default : System.Web.UI.Page
    {
        private string siteName = "ofer";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
                return;
            LoadData();
        }

        private void LoadData()
        {
            var row = new Model.DataBaseGateway().GetPage(siteName);
            if (row.Tables[0].Rows.Count == 1)
            {
                var body = row.Tables[0].Rows[0]["body"] as string;
                offerContent.Content = body;
            }
        }

        protected void updateBtn_Click(object sender, EventArgs e)
        {

            var body = offerContent.Content.Replace("\'", "\'\'");
            new Model.DataBaseGateway().UpdatePage(pageName: siteName, pageBody: body);
        }
    }
}